package com.ml.mall.service.asyn;

import com.ml.mall.bean.req.BaseDateRangeReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryOneReq;
import com.ml.mall.bean.req.admin.purchase.PurchaseQueryReportPageReq;
import com.ml.mall.bean.req.admin.supplier.SupplierQueryOneByCategoryReq;
import com.ml.mall.bean.req.admin.supplier.SupplierQueryOneByPurchaseReq;
import com.ml.mall.bean.req.admin.supplier.SupplierQueryOneReq;
import com.ml.mall.bean.req.admin.supplier.SupplierQueryPageReq;
import com.ml.mall.bean.req.admin.variant.VariantQueryOneReq;
import com.ml.mall.bean.req.admin.variant.VariantQueryPageReq;
import com.ml.mall.bean.res.admin.AdminIndustryQueryRes;
import com.ml.mall.bean.res.admin.AdminIndustrySupplierQueryRes;
import com.ml.mall.bean.res.admin.PurchaseByNameSpentRes;
import com.ml.mall.bean.res.admin.PurchaseReportPageRes;
import com.ml.mall.bean.res.admin.category.AdminCategoryQueryPageRes;
import com.ml.mall.bean.res.admin.category.AdminCategoryQueryReportPageRes;
import com.ml.mall.bean.res.admin.category.CategoryQuerySubcategoryTotalfeeRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryOneByCategoryRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryOneByPurchaseRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryPageRes;
import com.ml.mall.bean.res.admin.supplier.vo.SupplierQueryOneVO;
import com.ml.mall.bean.res.admin.variant.VariantQueryPageRes;
import com.ml.mall.bean.res.admin.variant.VariantQueryTopRes;
import com.ml.mall.bean.res.admin.variant.vo.VariantQueryOneVO;
import com.ml.mall.bean.res.admin.variant.vo.VariantQueryTopVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByCategoryVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByCountryVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByIndustryVO;
import com.ml.mall.bean.res.partner.PartnerSupplierQueryPageRes;
import com.ml.mall.bean.vo.DateValueVO;
import com.ml.mall.config.RedisConfiguration;
import com.ml.mall.mapper.AnalyticsAdminMapper;
import com.ml.mall.mapper.AnalyticsPartnerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.Future;

/**
 * Created by kyyang on 2021/6/8 22:32
 */
@Component
public class AnalyticsPartnerServiceAsyn {


    @Autowired
    private AnalyticsPartnerMapper analyticsPartnerMapper;


    /**
     * @description: 查询合作商下 时间范围内 供应商销售额
     * @author kyyang
     * @date 2021/6/30 22:29
     * @version 1.0
     */
    @Async
    public Future<BigDecimal> getPartnersRegisterCompanySales(BaseDateRangeReq req, Long companyId) {
        BigDecimal bigDecimal =  analyticsPartnerMapper.selectPartnersRegisterCompanySales(req.getTimeBegin(),req.getTimeEnd(),companyId);
        return new AsyncResult<>(bigDecimal);
    }

    /**
     * @description: 查询合作商下 时间范围内 供应商注册数量
     * @author kyyang
     * @date 2021/6/30 22:29
     * @version 1.0
     */
    @Async
    public Future<List<DateValueVO>> getPartnersRegisterCompanyListRegister(BaseDateRangeReq req, Long companyId) {
        List<DateValueVO> list =  analyticsPartnerMapper.selectPartnersRegisterCompanyListRegister(req.getTimeBegin(),req.getTimeEnd(),companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 查询供货商卖家每日销售
     * @author kyyang
     * @date 2021/6/30 22:59
     * @version 1.0
     */
    @Async
    public Future<List<DateValueVO>> getPartnerSupplierQueryReport(BaseDateRangeReq req, Long companyId) {
        List<DateValueVO> list =  analyticsPartnerMapper.selectPartnerSupplierQueryReport(req.getTimeBegin(),req.getTimeEnd(),companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 分页查询合作商下所有卖家 销售额 记录总数
     * @author kyyang
     * @date 2021/7/1 21:58
     * @version 1.0
     */
    @Async
    public Future<Integer> getPartnerSupplierQueryPageCount(PurchaseQueryReportPageReq req, Long companyId) {
        Integer count =  analyticsPartnerMapper.selectPartnerSupplierQueryPageCount(req.getTimeBegin(),req.getTimeEnd(),req.getCompanyName(),companyId);
        return new AsyncResult<>(count);
    }

    /**
     * @description: 分页查询合作商下所有卖家 销售额 记录明细
     * @author kyyang
     * @date 2021/7/1 21:58
     * @version 1.0
     */
    @Async
    public Future<List<PartnerSupplierQueryPageRes>> getPartnerSupplierQueryPageList(PurchaseQueryReportPageReq req, Long companyId) {
        List<PartnerSupplierQueryPageRes> list =  analyticsPartnerMapper.selectPartnerSupplierQueryPageList(req.getTimeBegin(),req.getTimeEnd(),req.getCompanyName(),companyId,req.getSortType(),req.getStart(),req.getEnd());
        return new AsyncResult<>(list);
    }


    /**
     * @description: 查询合作商下属供货商 目录销售额分页 总记录数
     * @author kyyang
     * @date 2021/7/1 22:45
     * @version 1.0
     */
    @Async
    public Future<Integer> selectPartnerCategoryQueryPageCount(String timeBegin, String timeEnd,  String categoryName,Long companyId) {
        Integer count =  analyticsPartnerMapper.selectPartnerCategoryQueryPageCount(timeBegin,timeEnd,categoryName,companyId);
        return new AsyncResult<>(count);

    }
    /**
     * @description: 查询合作商下属供货商 目录销售额分页 记录明细
     * @author kyyang
     * @date 2021/7/1 22:45
     * @version 1.0
     */
    @Async
    public Future<List<AdminCategoryQueryPageRes>> selectPartnerCategoryQueryPageList(String timeBegin, String timeEnd, int sortType, String categoryName, Long companyId, int start, int end) {
        List<AdminCategoryQueryPageRes> list =  analyticsPartnerMapper.selectPartnerCategoryQueryPageList(timeBegin,timeEnd,sortType,categoryName,companyId,start,end);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 查询时间范围内卖家销售情况
     * @author kyyang
     * @date 2021/8/10 23:10
     * @version 1.0
     */
    @Async
    public Future<List<DateValueVO>> getPartnersSupplierCompanyListSales(BaseDateRangeReq req, Long companyId) {
        List<DateValueVO> list =  analyticsPartnerMapper.selectPartnersSupplierCompanyListSales(req.getTimeBegin(),req.getTimeEnd(),companyId);
        return new AsyncResult<>(list);
    }
}
